package com.kexin.common.utils;

import java.util.ArrayList;
import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="分页信息", description="")
public class PageData<T> {

	@ApiModelProperty(value = "总数")
	private int total = 0;

	@ApiModelProperty(value = "每页显示条数")
	private int size = 10;

	@ApiModelProperty(value = "当前页")
	private int current = 1;

	@ApiModelProperty(value = "查询数据列表")
	private List<T> records = new ArrayList<T>();

	public PageData() {
		super();
	}

	public PageData(Page<T> page) {
		super();
		this.total = (int) page.getTotal();
		this.size = (int) page.getSize();
		this.current = (int) page.getCurrent();
		this.records = page.getRecords();
	}
}
